#include "app_buffer.h"
#include "log.h"

int main(int argc, char const *argv[])
{
    // 1.初始化n缓存
    Buffer *buffer = app_buffer_init(16);

    // 2.添加数据
    app_buffer_write(buffer, "helloworld", 11);

    // 3.读取数据
    char read_buff[5] = {0};
    app_buffer_read(buffer, read_buff, 5);
    log_info("read_buff:%.*s", 5, read_buff);

    // 4.读取数据
    char read_buff2[5] = {0};
    app_buffer_read(buffer, read_buff2, 5);
    log_info("read_buff:%.*s", 5, read_buff2);

    // 5.添加数据
    app_buffer_write(buffer, "0123456789", 9);

    // 6.读取数据(失败)
    char read_buff3[10] = {0};
    app_buffer_read(buffer, read_buff3, 10);
    log_info("read_buff:%.*s", 10, read_buff3);

    // 7.写入数据
    app_buffer_write(buffer, "111111111111111", 15);

    return 0;
}
